package seed_partner_user

import (
	"fmt"
	"gitee.com/theegg/go-brick/app/model/user/user_roles"
	"gitee.com/theegg/go-brick/app/service/app"
	"time"
)

func InitUserRolesSeed() {
	items := make(map[int]user_roles.UserRoles)

	items[1] = user_roles.UserRoles{
		Id:        1,
		Name:      "Vip用户",
		Sign:      "vip_type",
		Mark:      "",
		State:     true,
		CreatedAt: time.Now(),
	}

	items[2] = user_roles.UserRoles{
		Id:        2,
		Name:      "高级用户",
		Sign:      "senior_type",
		Mark:      "",
		State:     true,
		CreatedAt: time.Now(),
	}

	items[3] = user_roles.UserRoles{
		Id:        3,
		Name:      "普通用户",
		Sign:      "common_type",
		Mark:      "",
		State:     true,
		CreatedAt: time.Now(),
	}

	count := 0
	errCount := 0
	for _, item := range items {
		_, err := app.Db().Insert(item)
		if err != nil {
			fmt.Println(err.Error())
			errCount++
		} else {
			count++
		}
	}

	fmt.Printf("%5s|%25s|%10d|%8d|\n", "", "user_roles", count, errCount)
}
